-
Notifications
You must be signed in to change notification settings - Fork 15
Add spoly_is_convex #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d89edcf
to
a0be9d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general everything is ok except of some trivial issues.
@ggnmstr thank you for the PR. I think everything is ok except of some trivial issues. The tests should be fixed - could you please try to run tests without healpix:
I would also ask to start the commit comment from capital lettet as it was done for other commits. |
b61c748
to
5d264e6
Compare
fix_tests.patch |
@stepan-neretin7 Thank you, it works, seems like there's a problem with healpix on my computer. |
@ggnmstr please, start commit with capital letter |
@stepan-neretin7 wrote:
Do you mean the title of the pull request, @stepan-neretin7 ? The one commit message at https://github.com/postgrespro/pgsphere/pull/43/commits does start with a capital letter. |
Yes, I think it's a good idea. I also suggest that you also specify the issue number in the comment, so that he automatically linked it to the desired issue even before the merge. |
@ggnmstr There are some conflicts. Could you please do rebase on the newest version and fix the conflicts? |
@ggnmstr: CI failures. Please check and fix "make test" results. https://app.travis-ci.com/github/postgrespro/pgsphere/jobs/607409643 |
544f4f6
to
4570340
Compare
expected/init_test.out.in
Outdated
psql:pg_sphere.test.sql:8594: NOTICE: argument type pointkey is only a shell | ||
psql:pg_sphere.test.sql:8600: NOTICE: argument type pointkey is only a shell | ||
psql:pg_sphere.test.sql:9167: NOTICE: return type smoc is only a shell | ||
psql:pg_sphere.test.sql:9173: NOTICE: argument type smoc is only a shell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add linefeed to the end of this file.
expected/init_test_healpix.out.in
Outdated
psql:pg_sphere.test.sql:9181: NOTICE: return type smoc is only a shell | ||
psql:pg_sphere.test.sql:9187: NOTICE: argument type smoc is only a shell | ||
psql:pg_sphere.test.sql:9167: NOTICE: return type smoc is only a shell | ||
psql:pg_sphere.test.sql:9173: NOTICE: argument type smoc is only a shell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a linefeed to the end of this file.
2620fa7
to
a35e842
Compare
expected/init_test_healpix.out.in
Outdated
psql:pg_sphere.test.sql:9181: NOTICE: return type smoc is only a shell | ||
psql:pg_sphere.test.sql:9187: NOTICE: argument type smoc is only a shell | ||
psql:pg_sphere.test.sql:9167: NOTICE: return type smoc is only a shell | ||
psql:pg_sphere.test.sql:9173: NOTICE: argument type smoc is only a shell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are almost there! Change "9167" to "9195" on line 1. Change "9173" to "9201" on line 2.
To finalize PR the following changes are required:
|
@stepan-neretin7, this "return null" behavior is common among all functions, I don't think it is possible to change something just in place. |
but in your code you return false.. Very strange for me.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more minor tweaks, please, @ggnmstr. Thank you!
src/polygon.c
Outdated
wsv, | ||
crs; | ||
float8 cur = 0, | ||
prev = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the variables on lines 1487-1493 line up vertically for you? They don't line up vertically in the diff output here on GitHub.com.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/polygon.h
Outdated
/* | ||
* Checks whether a polygon is convex | ||
*/ | ||
Datum spherepoly_is_convex(PG_FUNCTION_ARGS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add spaces after Datum
so that spherepoly_is_convex
lines up vertically with the names of the functions above this.
doc/functions.sgm
Outdated
Spoly is convex | ||
</title> | ||
<para> | ||
Returns true if the specified spherical polygon is convex. Returns false otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line longer than 79 characters? I can't tell looking at it in the web browser here. If it is, please word-wrap it.
ff10fe4
to
e740d2c
Compare
I agree, it should return false. The third value is unnecessary. To fix it STRICT keyword should be removed in CREATE FUNCTION command. I also propose to update the tests by adding this case. |
@vitcpp. I fixed it and added a test, thanks for the information. |
for (int i = 0; i < poly->npts; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spherepoly_is_convex() functions seems to be ok as the first working version, but the code is not optimized. There are duplicate calculations in the for loop that can slowdown the performance.
There are some conflicts that should be resolved. @ggnmstr Could you please rebase your branch to the latest postgrespro/pgsphere version and fix conflicts? |
Yes, I agree with that. I think I'll optimize it a bit later. |
@@ -28,6 +28,7 @@ COMMENT ON FUNCTION spoly_deg(float8[]) IS | |||
refer to the same occurrence and cover its | |||
latitude and longitude, respectively.'; | |||
|
|||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to get make test
working.
expected/init_test.out.in
Outdated
@@ -33,3 +33,4 @@ psql:pg_sphere.test.sql:8622: NOTICE: argument type pointkey is only a shell | |||
psql:pg_sphere.test.sql:8628: NOTICE: argument type pointkey is only a shell | |||
psql:pg_sphere.test.sql:8634: NOTICE: argument type pointkey is only a shell | |||
psql:pg_sphere.test.sql:8640: NOTICE: argument type pointkey is only a shell | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add this blank line? I think it should be removed.
Take a look at the diff output at the bottom of the log here:
https://app.travis-ci.com/github/postgrespro/pgsphere/jobs/607714835
You need to change the line numbers in this file to match the results so that there are no differences.
expected/init_test_healpix.out.in
Outdated
@@ -1,2 +1,3 @@ | |||
psql:pg_sphere.test.sql:9207: NOTICE: return type smoc is only a shell | |||
psql:pg_sphere.test.sql:9213: NOTICE: argument type smoc is only a shell | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this blank line. In this file, change "9207" to "9221" and change "9213" to "9227".
006ad50
to
e642169
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you for your contribution and perseverance, @ggnmstr!
@ggnmstr Could you please do one more iteration - re-sync your branch with this repo, resolve conflicts and force-push your changes? Your PR will be the next. Thank you in advance! |
@vitcpp, Ok, I did it. The tests are OK, I guess, I just realized that I was typing "HEAPLIX" all the time and then wondering why is it not working on my PC |
@ggnmstr Thank you very much! |
Adds function to determine whether the spoly is convex.
Algorithm based on
https://mathoverflow.net/questions/193569/determining-orientation-of-spherical-polygons